<?php


namespace api\modules\v1\controllers;
use api\controllers\OnAuthController;
use common\models\byxcx\Cate;
use common\models\byxcx\Team;

class TeamController extends OnAuthController
{
    public $modelClass = '';
    protected $authOptional = ['banner','banne','team','project','service'];
    public function actionBanner(){
        $data=Cate::find()
            ->from('{{%byxcx_cate}} a')
            ->join('join','{{%byxcx_article}} b','b.cate_id=a.id')
            ->select('b.title,b.description,b.cover,b.content')
            ->where(['pid'=>97])
            ->asArray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //公司组织构架图
    public function actionBanne(){
        $data=Cate::find()
            ->from('{{%byxcx_cate}} a')
            ->join('join','{{%byxcx_chart}} b','b.cate_id=a.id')
            ->select('a.title,b.cover')
            ->where(['pid'=>97])
            ->asArray()
            ->all();
        if ($data) {
            return $data;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    public function actionTeam(){
        $data=Cate::find()
            ->from('{{%byxcx_cate}} a')
            ->join('join','{{%byxcx_team}} b','b.cate_id=a.id')
            ->select('b.name,b.position,b.description,b.cover,b.cate_id')
            ->where(['pid'=>97])
            ->asArray()
            ->all();
        $a = array_column($data,'cate_id');
        $arr =Cate::find()
            ->where(['id'=>$a[0]])
            ->select('title')
            ->asArray()
            ->one();
        $b = array_merge($data,$arr);
        if ($b) {
            return $b;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //团队展示
    public function actionExhibition(){

    }

    //开发流程
    public function actionProject(){
        $data=Cate::find()
            ->from('{{%byxcx_cate}} a')
            ->join('join','{{%byxcx_chart}} b','b.cate_id=a.id')
            ->select('b.title,b.description,b.cover,b.cate_id')
            ->where(['tag'=>1,'pid'=>95])
            ->asArray()
            ->all();
        $a = array_column($data,'cate_id');
        $arr =Cate::find()
            ->where(['id'=>$a[0]])
            ->select('title,desc')
            ->asArray()
            ->one();
        $b = array_merge($data,$arr);
        if ($b) {
            return $b;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
    //服务优势
    public function actionService(){
        $data=Cate::find()
            ->from('{{%byxcx_cate}} a')
            ->join('join','{{%byxcx_chart}} b','b.cate_id=a.id')
            ->select('b.title,b.description,b.cover,b.cate_id')
            ->where(['tag'=>2,'pid'=>95])
            ->asArray()
            ->all();
        $a = array_column($data,'cate_id');
        $arr =Cate::find()
            ->where(['id'=>$a[0]])
            ->select('title,desc')
            ->asArray()
            ->one();
        $b = array_merge($data,$arr);
        if ($b) {
            return $b;
        } else {
            return ['code' => 0, 'msg' => "失败", 'data' => []];
        }
    }
}